<?php
namespace App\Repositories;

use App\Models\SimulatBook;

class SimulatBookRepository extends BaseRepository
{
    public function __construct(
        SimulatBook $simulatbook
    )
    {
        $this->model = $simulatbook;
    }


    public function index($data, $extra = '', $size = '')
    {
        $list = $this->model->limit($size)->offset(($data['page'] - 1) * $size)->where('km', $data['km'])->where('level', 1)->get();

        if($list){

            foreach($list as $f_list)
            {
                $f_list->list = $this->model->where('pid', $f_list->id)->get();
            }
        }

        return $list;

    }

    /**
     * 存储odb
     * @param $inputs
     */
    public function store($inputs, $extra = '')
    {

    }


    /**
     * 更新
     * @param $id
     * @param $input
     * @return mixed
     */
    public function update($id, $input,$extra = '')
    {
        $model = $this->getById($id);
        return $this->save($model,$input);
    }


    /**
     * 编辑特定id资源
     * @param  int $id 资源id
     * @param  string|array $extra 可选额外传入的参数
     * @return Illuminate\Support\Collection
     */
    public function edit($id, $extra)
    {

    }

    /**
     * @param $model
     * @param $inputs
     * @param bool $falg
     * @return mixed
     */
    public function save($model , $inputs , $falg = false)
    {
        return $model;
    }

}